/*
The MIT License
Copyright (c) 2019 Lehrstuhl Informatik 11 - RWTH Aachen University
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE

This file is part of embeddedRTPS.

Author: i11 - Embedded Software, RWTH Aachen University
*/

#ifndef RTPS_STATELESSREADER_H
#define RTPS_STATELESSREADER_H

#include "rtps/entities/Reader.h"
#include "rtps/messages/MessageTypes.h"

struct rtps_StatelessReader {
	struct rtps_Reader m_reader;
	sys_mutex_t m_mutex;
	ddsReaderCallback_fp m_callback;
	void *m_callee;
};
typedef struct rtps_StatelessReader StatelessReader;

void rtps_StatelessReader_init(struct rtps_StatelessReader *slReader,
			    const TopicData *attributes);
void rtps_StatelessReader_newChange(struct rtps_StatelessReader *slReader,
				const ReaderCacheChange *cacheChange);
void rtps_StatelessReader_registerCallback(struct rtps_StatelessReader *slReader,
		ddsReaderCallback_fp cb, void *callee);
bool rtps_StatelessReader_onNewHeartbeat(struct rtps_StatelessReader *slReader, const SubmessageHeartbeat *msg, 
		const GuidPrefix_t *remotePrefix);
bool rtps_StatelessReader_addNewMatchedWriter(struct rtps_StatelessReader *slReader,
		const WriterProxy *newProxy);
void rtps_StatelessReader_removeWriter(struct rtps_StatelessReader *slReader,
		const Guid_t *guid);
void rtps_StatelessReader_removeWriterOfParticipant(struct rtps_StatelessReader *slReader,
		const GuidPrefix_t *guidPrefix);
void rtps_StatelessReader_Construct(struct rtps_StatelessReader *slReader);
void rtps_StatelessReader_Destruct(struct rtps_StatelessReader *slReader);
#endif // RTPS_STATELESSREADER_H
